import Vue from 'vue'
import Router from 'vue-router'

const originalPush = Router.prototype.push
Router.prototype.push = function push (location, onResolve, onReject) {
  if (onResolve || onReject){
    return originalPush.call(this, location, onResolve, onReject)
  }
  return originalPush.call(this, location).catch(err => err)
}
Vue.use(Router);
export default new Router({
  // mode: 'history',
  routes: [
    {
      path: '/not-found',
      component: ()=>import('@/pages/other-pages/NotFound')
    },
    {
      path: '*',
      redirect: '/not-found'
    },
    {
      path: '/',
      meta: {index: 1},
      component: ()=>import('@/pages/notes/index')
    },
    {
      path: '/notes/detail/:id',
      meta: {index: 2},
      component: ()=>import('@/pages/notes/detail')
    },
    {
      path: '/admin/notes',
      meta: {index: 3},
      component: ()=>import('@/pages/admin/list')
    },
    {
      path: '/admin/notes/edit',
      meta: {index: 4},
      component: ()=>import('@/pages/admin/edit')
    }
  ]
})
